export const sendToServer = (socket: any, message: any) => {
    if (socket.readyState === WebSocket.OPEN) {
        socket.send(JSON.stringify(message));
        if (message.type !== 'pong') {
            console.log(`已发送消息到服务器${message.type}`);
        } 
   
    } else {
        console.log('WebSocket 连接未打开，无法发送消息');
    }
}